﻿Imports System
Imports System.IO
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Formatters.Binary
''' <summary>
''' 用于储存计算结果的类
''' </summary>
''' <remarks></remarks>
<Serializable()> Public Class NameAndData
    Private m_Name As String

    Private m_MaxValueCon As Double = 9999999 '网格最大浓度值
    Private m_MinValueCon As Double = 0 '网格最小浓度值
    Private m_GridCon(-1, -1) As ResultCon '用于储存网格中的浓度数据
    Private m_GridMaxCon As New ResultCon  '储存网格中浓度最大值
    Private m_DiscCon(-1) As ResultCon '储存关心点浓度最大的数据

    Private m_MaxValueDEPOS As Double = 9999999 '网格最大总沉积值
    Private m_MinValueDEPOS As Double = 0 '网格最小总沉积值
    Private m_GridDEPOS(-1, -1) As ResultDEPOS '用于储存网格中的总沉积度数据
    Private m_GridMaxDEPOS As New ResultDEPOS  '储存网格中总沉积最大值
    Private m_DiscDEPOS(-1) As ResultDEPOS '储存关心点总沉积最大的数据

    Private m_MaxValueDDEP As Double = 9999999 '网格最大干沉积值
    Private m_MinValueDDEP As Double = 0 '网格最小干沉积值
    Private m_GridDDEP(-1, -1) As ResultDDEP '用于储存网格中的浓度数据
    Private m_GridMaxDDEP As New ResultDDEP  '储存网格中浓度最大值
    Private m_DiscDDEP(-1) As ResultDDEP '储存关心点浓度最大的数据

    Private m_MaxValueWDEP As Double = 9999999 '网格最大湿沉积值
    Private m_MinValueWDEP As Double = 0 '网格最湿沉积值
    Private m_GridWDEP(-1, -1) As ResultWDEP '用于储存网格中的浓度数据
    Private m_GridMaxWDEP As New ResultWDEP  '储存网格中浓度最大值
    Private m_DiscWDEP(-1) As ResultWDEP '储存关心点浓度最大的数据

    Private m_SubGridCon(-1)(,) As ResultCon '用于储存嵌套网格中的浓度数据
    Private m_SubGridDEPOS(-1)(,) As ResultDEPOS '用于储存嵌套网格中的总沉积度数据
    Private m_SubGridDDEP(-1)(,) As ResultDDEP '用于储存嵌套网格中的浓度数据
    Private m_SubGridWDEP(-1)(,) As ResultWDEP '用于储存嵌套网格中的浓度数据


    ''' <summary>
    ''' 计算结果的文件的名称
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property Name() As String
        Get
            Return Me.m_Name
        End Get
        Set(ByVal value As String)
            Me.m_Name = value
        End Set
    End Property

    ''' <summary>
    ''' 网格点的最大值 
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property MaxValueCon() As Double
        Get
            Return Me.m_MaxValueCon
        End Get
        Set(ByVal value As Double)
            Me.m_MaxValueCon = value
        End Set
    End Property

    ''' <summary>
    ''' 网格点的最小值
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property MinValueCon() As Double
        Get
            Return Me.m_MinValueCon
        End Get
        Set(ByVal value As Double)
            Me.m_MinValueCon = value
        End Set
    End Property
    ''' <summary>
    ''' 储存网格中的数据。按行、列储存
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property GridCon() As ResultCon(,) '用于储存网格中的数据
        Get
            Return Me.m_GridCon
        End Get
        Set(ByVal value As ResultCon(,))
            Me.m_GridCon = value
        End Set
    End Property
    ''' <summary>
    ''' 储存网格中的最大值
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property GridMaxCon() As ResultCon
        Get
            Return Me.m_GridMaxCon
        End Get
        Set(ByVal value As ResultCon)
            Me.m_GridMaxCon = value
        End Set
    End Property
    ''' <summary>
    ''' 储存关心点的数据。表示多个关心点，每个关心点都有各自的数据。
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property DiscCon() As ResultCon()
        Get
            Return Me.m_DiscCon
        End Get
        Set(ByVal value As ResultCon())
            Me.m_DiscCon = value
        End Set
    End Property
    ''' <summary>
    ''' 网格最大总沉积值
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property MaxValueDEPOS() As Double
        Get
            Return m_MaxValueDEPOS
        End Get
        Set(ByVal value As Double)
            m_MaxValueDEPOS = value
        End Set
    End Property
    ''' <summary>
    ''' 网格最小总沉积值
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property MinValueDEPOS() As Double
        Get
            Return m_MinValueDEPOS
        End Get
        Set(ByVal value As Double)
            m_MinValueDEPOS = value
        End Set
    End Property
    ''' <summary>
    ''' 用于储存网格中的总沉积度数据
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property GridDEPOS() As ResultDEPOS(,)
        Get
            Return m_GridDEPOS
        End Get
        Set(ByVal value As ResultDEPOS(,))
            m_GridDEPOS = value
        End Set
    End Property
    ''' <summary>
    ''' 储存网格中总沉积最大值
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property GridMaxDEPOS() As ResultDEPOS
        Get
            Return m_GridMaxDEPOS
        End Get
        Set(ByVal value As ResultDEPOS)
            m_GridMaxDEPOS = value
        End Set
    End Property
    ''' <summary>
    ''' 储存关心点总沉积最大的数据
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property DiscDEPOS() As ResultDEPOS() '
        Get
            Return m_DiscDEPOS
        End Get
        Set(ByVal value As ResultDEPOS())
            m_DiscDEPOS = value
        End Set
    End Property
    ''' <summary>
    ''' 网格最大干沉积值
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property MaxValueDDEP() As Double '
        Get
            Return m_MaxValueDDEP
        End Get
        Set(ByVal value As Double)
            m_MaxValueDDEP = value
        End Set
    End Property
    ''' <summary>
    ''' 网格最小干沉积值
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property MinValueDDEP() As Double
        Get
            Return m_MinValueDDEP
        End Get
        Set(ByVal value As Double)
            m_MinValueDDEP = value
        End Set
    End Property
    ''' <summary>
    ''' 用于储存网格中的干沉积数据
    ''' </summary>
    ''' <remarks></remarks>
    Property GridDDEP() As ResultDDEP(,)
        Get
            Return m_GridDDEP
        End Get
        Set(ByVal value As ResultDDEP(,))
            m_GridDDEP = value
        End Set
    End Property
    ''' <summary>
    ''' 储存网格中干沉积最大值
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property GridMaxDDEP() As ResultDDEP
        Get
            Return m_GridMaxDDEP
        End Get
        Set(ByVal value As ResultDDEP)
            m_GridMaxDDEP = value
        End Set
    End Property
    ''' <summary>
    ''' 储存关心点干沉积最大的数据
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property DiscDDEP() As ResultDDEP() '
        Get
            Return m_DiscDDEP
        End Get
        Set(ByVal value As ResultDDEP())
            m_DiscDDEP = value
        End Set
    End Property

    ''' <summary>
    ''' 网格最大湿沉积值
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property MaxValueWDEP() As Double
        Get
            Return m_MaxValueWDEP
        End Get
        Set(ByVal value As Double)
            m_MaxValueWDEP = value
        End Set
    End Property

    ''' <summary>
    ''' 网格最小湿沉积值
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property MinValueWDEP() As Double  '
        Get
            Return m_MinValueWDEP
        End Get
        Set(ByVal value As Double)
            m_MinValueWDEP = value
        End Set
    End Property
    ''' <summary>
    ''' 用于储存网格中的湿沉积数据
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property GridWDEP() As ResultWDEP(,)  '
        Get
            Return m_GridWDEP
        End Get
        Set(ByVal value As ResultWDEP(,))
            m_GridWDEP = value
        End Set
    End Property
    ''' <summary>
    ''' 储存网格中湿沉积最大值
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property GridMaxWDEP() As ResultWDEP  '
        Get
            Return m_GridMaxWDEP
        End Get
        Set(ByVal value As ResultWDEP)
            m_GridMaxWDEP = value
        End Set
    End Property
    ''' <summary>
    ''' 储存关心点湿沉积最大的数据
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property DiscWDEP() As ResultWDEP() '
        Get
            Return m_DiscWDEP
        End Get
        Set(ByVal value As ResultWDEP())
            m_DiscWDEP = value
        End Set
    End Property
    ''' <summary>
    ''' 用于储存嵌套网格中的浓度数据
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property SubGridCon() As ResultCon()(,)
        Get
            Return Me.m_SubGridCon
        End Get
        Set(ByVal value As ResultCon()(,))
            Me.m_SubGridCon = value
        End Set
    End Property
    ''' <summary>
    ''' 用于储存嵌套网格中的总沉积度数据
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property SubGridDEPOS() As ResultDEPOS()(,)
        Get
            Return Me.m_SubGridDEPOS
        End Get
        Set(ByVal value As ResultDEPOS()(,))
            Me.m_SubGridDEPOS = value
        End Set
    End Property
    ''' <summary>
    ''' 用于储存嵌套网格中的浓度数据
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property SubGridDDEP() As ResultDDEP()(,)
        Get
            Return Me.m_SubGridDDEP
        End Get
        Set(ByVal value As ResultDDEP()(,))
            Me.m_SubGridDDEP = value
        End Set
    End Property
    ''' <summary>
    ''' 用于储存嵌套网格中的浓度数据
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property SubGridWDEP() As ResultWDEP()(,)
        Get
            Return Me.m_SubGridWDEP
        End Get
        Set(ByVal value As ResultWDEP()(,))
            Me.m_SubGridWDEP = value
        End Set
    End Property
    

    ''' <summary>
    ''' 从AERMOD.OUT文件中获取相应的数据
    ''' </summary>
    ''' <param name="strAERMODOUT">输出文件名的字符串数组</param>
    ''' <param name="Receptor">接受点</param>
    ''' <param name="IsDep">沉降</param>
    ''' <param name="strHIGHEST">第几大</param>
    ''' <param name="strAerageTime">平均时间</param>
    ''' <param name="strGroup">组</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetDataFromAERMODOUT(ByVal strAERMODOUT As String(), ByVal Receptor As Receptor, ByVal IsDep As Boolean, ByVal strAerageTime As String, ByVal strHIGHEST As String, ByVal strGroup As String, ByVal IsAnalisis As Boolean, ByVal GroupSourceCount As Integer, ByVal version As String) As Boolean
        If GetGridDateFromAERMODOUT(strAERMODOUT, Receptor, IsDep, strAerageTime, strHIGHEST, strGroup, IsAnalisis, GroupSourceCount, version) = False Then
            Return False
        End If
        If GetDiscDateFromAERMODOUT(strAERMODOUT, Receptor, IsDep, strAerageTime, strHIGHEST, strGroup, GroupSourceCount, Version) = False Then
            Return False
        End If
        If GetGridMaxDateFromAERMODOUT(strAERMODOUT, Receptor, IsDep, strAerageTime, strHIGHEST, strGroup, version) = False Then
            Return False
        End If
        Return True
    End Function
    ''' <summary>
    ''' 获取网格点前n大给定短期间的浓度分布
    ''' </summary>
    ''' <param name="strAERMODOUT">输出文件名内容的一维数组</param>
    ''' <param name="Receptor">接受点</param>
    ''' <param name="IsDep">沉降</param>
    ''' <param name="strHIGHEST">第几大</param>
    ''' <param name="strAerageTime">平均时间</param>
    ''' <param name="strGroup">组</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function GetGridDateFromAERMODOUT(ByVal strAERMODOUT As String(), ByVal Receptor As Receptor, ByVal IsDep As Boolean, ByVal strAerageTime As String, ByVal strHIGHEST As String, ByVal strGroup As String, ByVal IsAnalisis As Boolean, ByVal GroupSourceCount As Integer, ByVal version As String) As Boolean
        If IsAnalisis = True Then

            Dim AGridData(,) As ResultCon = GetCustomGridCon(strAERMODOUT, Receptor.SubGridCart(0).Ynum, Receptor.SubGridCart(0).Xnum, IsDep, strAerageTime, strHIGHEST, strGroup, GroupSourceCount, Receptor.SubGridCart(0).Netid, version)
            If AGridData IsNot Nothing Then
                Me.m_GridCon = AGridData
            End If
            ReDim Me.m_SubGridCon(Receptor.SubGridCart.Length - 1)
            For i As Integer = 0 To Receptor.SubGridCart.Length - 1
                Dim BGridCon(,) As ResultCon = GetCustomGridCon(strAERMODOUT, Receptor.SubGridCart(i).Ynum, Receptor.SubGridCart(i).Xnum, IsDep, strAerageTime, strHIGHEST, strGroup, GroupSourceCount, Receptor.SubGridCart(i).Netid, version)
                If BGridCon IsNot Nothing Then
                    Me.m_SubGridCon(i) = BGridCon
                End If
            Next
            'ReDim Me.m_GridCon(Receptor.SubGridCart(0).Ynum - 1, Receptor.SubGridCart(0).Xnum - 1)
            'Dim strLine As String = "" '读取一行
            'Dim nCol As Integer = 0 '用于记列数
            'Dim RowPage As Integer = 0 '用于标记行的页数
            'Dim ColPage As Integer = 0 '用于标记列的页数
            'For nAllString As Integer = 0 To strAERMODOUT.Length - 1
            '    strLine = strAERMODOUT(nAllString) '读取一行
            '    If strLine.Contains(strHIGHEST) And strLine.Contains(strAerageTime) And strLine.Contains("CONCENTRATION") And strLine.Contains(strGroup.ToUpper) Then
            '        '开始计数
            '        nAllString += 3 '
            '        If GroupSourceCount > 19 Then
            '            nAllString += 2
            '        ElseIf GroupSourceCount > 7 Then
            '            nAllString += 1
            '        End If
            '        Dim strLineLine4 As String = strAERMODOUT(nAllString)
            '        If strLineLine4.Contains("NETWORK") Then '用于判断是不是网格点。如果是按网格点读取数据
            '            nAllString += 7 '
            '            '开始读取网格数据
            '            Dim strDate As String
            '            For i As Integer = RowPage * 40 To RowPage * 40 + 39
            '                nAllString += 1
            '                strDate = strAERMODOUT(nAllString)
            '                For j As Integer = ColPage * 5 To ColPage * 5 + 4
            '                    If strDate.Substring(11 + nCol * 24, 13) = "*************" Then
            '                        MessageBox.Show("您输入的污染物排放源强可能过大，已经超出最大范围。")
            '                        Return False
            '                    End If
            '                    Me.m_GridCon(i, j).con = strDate.Substring(11 + nCol * 24, 13)
            '                    Me.m_GridCon(i, j).dateD = strDate.Substring(26 + nCol * 24, 8)

            '                    If j >= Receptor.SubGridCart(0).Xnum - 1 Then
            '                        Exit For
            '                    End If
            '                    nCol += 1
            '                Next
            '                nCol = 0
            '                If i >= Receptor.SubGridCart(0).Ynum - 1 Then
            '                    ColPage += 1
            '                    RowPage = -1
            '                    Exit For
            '                End If
            '            Next
            '            RowPage += 1
            '        End If
            '    End If

            'Next
            '根据网格数据求最大值和最小值
            Me.m_MaxValueCon = Me.m_GridCon(0, 0).con
            Me.m_MinValueCon = Me.m_GridCon(0, 0).con
            For i As Integer = 0 To Receptor.SubGridCart(0).Ynum - 1
                For j As Integer = 0 To Receptor.SubGridCart(0).Xnum - 1
                    If Me.m_MaxValueCon < Me.m_GridCon(i, j).con Then
                        Me.m_MaxValueCon = Me.m_GridCon(i, j).con
                    End If
                    If Me.m_MinValueCon > Me.m_GridCon(i, j).con Then
                        Me.m_MinValueCon = Me.m_GridCon(i, j).con
                    End If
                Next
            Next
            Return True
        End If
        Return True
    End Function

    Private Function GetCustomGridCon(ByVal strAERMODOUT As String(), ByVal Ynum As Integer, ByVal Xnum As Integer, ByVal IsDep As Boolean, ByVal strAerageTime As String, ByVal strHIGHEST As String, ByVal strGroup As String, ByVal GroupSourceCount As Integer, ByVal strGrid As String, ByVal version As String) As ResultCon(,)
        Dim nVer As Integer = 0
        If Version = "07026" Then
            nVer = 0
        ElseIf Version = "09292" Then
            nVer = 1
        End If
        Dim AGridData(Ynum - 1, Xnum - 1) As ResultCon
        Dim strLine As String = "" '读取一行
        Dim nCol As Integer = 0 '用于记列数
        Dim RowPage As Integer = 0 '用于标记行的页数
        Dim ColPage As Integer = 0 '用于标记列的页数
        For nAllString As Integer = 0 To strAERMODOUT.Length - 1
            strLine = strAERMODOUT(nAllString) '读取一行
            If strLine.Contains(strHIGHEST) And strLine.Contains(strAerageTime) And strLine.Contains("CONCENTRATION") And strLine.Contains(strGroup.ToUpper) Then
                '开始计数
                nAllString += 3 '
                If GroupSourceCount > 19 Then
                    nAllString += 2
                ElseIf GroupSourceCount > 7 Then
                    nAllString += 1
                End If
                Dim strLineLine4 As String = strAERMODOUT(nAllString)
                If strLineLine4.Contains("NETWORK") And strLineLine4.Contains(strGrid.ToUpper) Then '用于判断是不是网格点。如果是按网格点读取数据
                    nAllString += 7 '
                    '开始读取网格数据
                    Dim strDate As String
                    For i As Integer = RowPage * 40 To RowPage * 40 + 39
                        nAllString += 1
                        strDate = strAERMODOUT(nAllString)
                        For j As Integer = ColPage * 5 To ColPage * 5 + 4
                            If strDate.Substring(nVer + 11 + nCol * 24, 13) = "*************" Then
                                MessageBox.Show("您输入的污染物排放源强可能过大，已经超出最大范围。")
                                Return Nothing
                            End If
                            AGridData(i, j).con = strDate.Substring(nVer + 11 + nCol * 24, 13)
                            AGridData(i, j).dateD = strDate.Substring(nVer + 26 + nCol * 24, 8)

                            If j >= Xnum - 1 Then
                                Exit For
                            End If
                            nCol += 1
                        Next
                        nCol = 0
                        If i >= Ynum - 1 Then
                            ColPage += 1
                            RowPage = -1
                            Exit For
                        End If
                    Next
                    RowPage += 1
                End If
            End If

        Next
        Return AGridData
    End Function


    ''' <summary>
    ''' 获取网格点前n大给定短期间的浓度分布
    ''' </summary>
    ''' <param name="strAERMODOUT">输出文件名内容的一维数组</param>
    ''' <param name="Receptor">接受点</param>
    ''' <param name="IsDep">沉降</param>
    ''' <param name="strHIGHEST">第几大</param>
    ''' <param name="strAerageTime">平均时间</param>
    ''' <param name="strGroup">组</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function GetGridMaxDateFromAERMODOUT(ByVal strAERMODOUT As String(), ByVal Receptor As Receptor, ByVal IsDep As Boolean, ByVal strAerageTime As String, ByVal strHIGHEST As String, ByVal strGroup As String, ByVal version As String) As Boolean
        Dim nVer As Integer = 0
        If version = "07026" Then
            nVer = 0
        ElseIf version = "09292" Then
            nVer = 0
        End If
        Dim strLine As String = "" '读取一行
        Dim nCol As Integer = 0 '用于记列数
        Dim RowPage As Integer = 0 '用于标记行的页数
        Dim ColPage As Integer = 0 '用于标记列的页数
        For nAllString As Integer = 0 To strAERMODOUT.Length - 1
            Try
                strLine = strAERMODOUT(nAllString) '读取一行
                If strLine.Contains("SUMMARY OF") And strLine.Contains(strAerageTime) And strLine.Contains("RESULTS") Then
                    '开始计数
                    nAllString += 5

                    Dim strLineLine4 As String = strAERMODOUT(nAllString)
                    If strLineLine4.Contains("NETWORK") Then '用于判断是不是网格点。如果是按网格点读取数据
                        nAllString += 1
                        strLineLine4 = strAERMODOUT(nAllString)
                        If strLineLine4.Contains("CONC") Then '浓度。用ON来区分指定时区的浓度和全时段的浓度
                            nAllString += 2
                            '开始读取网格数据
                            Dim strDate As String
                            For i As Integer = 0 To strAERMODOUT.Length - 10 - nAllString
                                nAllString += 1
                                strDate = strAERMODOUT(nAllString)
                                If strDate.Contains("*** RECEPTOR TYPES") Then
                                    Exit Try
                                End If
                                If strDate.Contains(strGroup.ToUpper) = True And strDate.Contains("ON") Then
                                    m_GridMaxCon.con = strDate.Substring(nVer + 33, 13)
                                    m_GridMaxCon.dateD = strDate.Substring(nVer + 51, 8)
                                    m_GridMaxCon.x = strDate.Substring(nVer + 65, 11)
                                    m_GridMaxCon.y = strDate.Substring(nVer + 78, 11)
                                    Exit Try
                                End If
                            Next
                        ElseIf strLineLine4.Contains("TOTAL DEPO") Then '总沉降
                            nAllString += 2
                            '开始读取网格数据
                            Dim strDate As String
                            For i As Integer = 0 To strAERMODOUT.Length - 10 - nAllString
                                nAllString += 1
                                strDate = strAERMODOUT(nAllString)
                                If strDate.Contains("*** RECEPTOR TYPES") Then
                                    Exit Try
                                End If
                                If strDate.Contains(strGroup.ToUpper) = True And strDate.Contains("ON") Then
                                    m_GridMaxDEPOS.DEPOS = strDate.Substring(nVer + 33, 13)
                                    m_GridMaxDEPOS.dateD = strDate.Substring(nVer + 51, 8)
                                    m_GridMaxDEPOS.x = strDate.Substring(nVer + 65, 11)
                                    m_GridMaxDEPOS.y = strDate.Substring(nVer + 78, 11)
                                    Exit Try
                                End If
                            Next
                        ElseIf strLineLine4.Contains("DRY DEPO") Then '干沉降
                            nAllString += 2
                            '开始读取网格数据
                            Dim strDate As String
                            For i As Integer = 0 To strAERMODOUT.Length - 10 - nAllString
                                nAllString += 1
                                strDate = strAERMODOUT(nAllString)
                                If strDate.Contains("*** RECEPTOR TYPES") Then
                                    Exit Try
                                End If
                                If strDate.Contains(strGroup.ToUpper) = True And strDate.Contains("ON") Then
                                    m_GridMaxDDEP.DDEP = strDate.Substring(nVer + 33, 13)
                                    m_GridMaxDDEP.dateD = strDate.Substring(nVer + 51, 8)
                                    m_GridMaxDDEP.x = strDate.Substring(nVer + 65, 11)
                                    m_GridMaxDDEP.y = strDate.Substring(nVer + 78, 11)
                                    Exit Try
                                End If
                            Next

                        ElseIf strLineLine4.Contains("WET DEPO") Then '湿沉降
                            nAllString += 2
                            '开始读取网格数据
                            Dim strDate As String
                            For i As Integer = 0 To strAERMODOUT.Length - 10 - nAllString
                                nAllString += 1
                                strDate = strAERMODOUT(nAllString)
                                If strDate.Contains("*** RECEPTOR TYPES") Then
                                    Exit Try
                                End If
                                If strDate.Contains(strGroup.ToUpper) = True And strDate.Contains("ON") Then
                                    m_GridMaxWDEP.WDEP = strDate.Substring(nVer + 33, 13)
                                    m_GridMaxWDEP.WDEP = strDate.Substring(nVer + 51, 8)
                                    m_GridMaxWDEP.x = strDate.Substring(nVer + 65, 11)
                                    m_GridMaxWDEP.y = strDate.Substring(nVer + 78, 11)
                                    Exit Try
                                End If
                            Next

                        End If
                    End If
                End If
            Catch ex As Exception

            End Try

        Next
        Return True
    End Function
    ''' <summary>
    ''' 从AERMOD.OUT文件中获取相应的期间平均网格和关心点数据
    ''' </summary>
    ''' <param name="strAERMODOUT">AERMOD.OUT内容数组</param>
    ''' <param name="Receptor">网格和关心点对象</param>
    ''' <param name="IsDep">是否考虑沉降</param>
    ''' <param name="strGroup">污染物组源</param>
    ''' <remarks></remarks>
    Public Function GetPeriodDate(ByVal strAERMODOUT As String(), ByVal Receptor As Receptor, ByVal IsDep As Boolean, ByVal strGroup As String, ByVal GroupSourceCount As Integer, ByVal version As String) As Boolean
        '获取期间平均网格点浓度
        If GetGridPeriodDateFromAERMODOUT(strAERMODOUT, Receptor, IsDep, strGroup, GroupSourceCount, Version) = False Then
            Return False
        End If
        '获取期间平均离散点浓度
        If GetDiscPeriodDateFromAERMODOUT(strAERMODOUT, Receptor, IsDep, strGroup, GroupSourceCount, version) = False Then '浓度、沉积
            Return False
        End If
        '获取期间平均中网格点最大浓度
        If GetGridPeriodMaxDataFromAERMODOUT(strAERMODOUT, Receptor, IsDep, strGroup, version) = False Then
            Return False
        End If
        Return True
    End Function

    ''' <summary>
    ''' 从AERMOD.OUT文件中获取相应的期间平均网格数据
    ''' </summary>
    ''' <param name="strAERMODOUT">AERMOD.OUT文件名及路径</param>
    ''' <param name="Receptor">网格和关心点对象</param>
    ''' <param name="IsDep">是否考虑沉降</param>
    ''' <param name="strGroup">污染物组源</param>
    ''' <param name="GroupSourceCount">污染物组源中污染源的个数</param>
    ''' <remarks></remarks>
    Public Function GetGridPeriodDateFromAERMODOUT(ByVal strAERMODOUT As String(), ByVal Receptor As Receptor, ByVal IsDep As Boolean, ByVal strGroup As String, ByVal GroupSourceCount As Integer, ByVal version As String) As Boolean

        ReDim Me.m_GridCon(Receptor.SubGridCart(0).Ynum - 1, Receptor.SubGridCart(0).Xnum - 1)
        Dim AGridCon(,) As ResultCon = GetCustomPeriodGridCon(strAERMODOUT, Receptor.SubGridCart(0).Ynum, Receptor.SubGridCart(0).Xnum, strGroup, GroupSourceCount, Receptor.SubGridCart(0).Netid, version)
        If AGridCon IsNot Nothing Then
            Me.m_GridCon = AGridCon
        End If
        ReDim Me.m_SubGridCon(Receptor.SubGridCart.Length - 1)
        For i As Integer = 0 To Receptor.SubGridCart.Length - 1
            Dim BGridCon(,) As ResultCon = GetCustomPeriodGridCon(strAERMODOUT, Receptor.SubGridCart(i).Ynum, Receptor.SubGridCart(i).Xnum, strGroup, GroupSourceCount, Receptor.SubGridCart(i).Netid, version)
            If BGridCon IsNot Nothing Then
                Me.m_SubGridCon(i) = BGridCon
            End If
        Next

        'ReDim Me.m_GridCon(Receptor.SubGridCart(0).Ynum - 1, Receptor.SubGridCart(0).Xnum - 1)
        'Dim strLine As String = "" '读取一行
        'Dim nCol As Integer = 0 '用于记列数
        'Dim RowPage As Integer = 0 '用于标记行的页数
        'Dim ColPage As Integer = 0 '用于标记列的页数
        'For nAllString As Integer = 0 To strAERMODOUT.Length - 1
        '    strLine = strAERMODOUT(nAllString) '读取一行
        '    If strLine.Contains("PERIOD") And strLine.Contains("CONCENTRATION") And strLine.Contains(strGroup.ToUpper) Then
        '        '开始计数

        '        nAllString += 3
        '        If GroupSourceCount > 19 Then
        '            nAllString += 2
        '        ElseIf GroupSourceCount > 7 Then
        '            nAllString += 1
        '        End If
        '        Dim strLineLine4 As String = strAERMODOUT(nAllString)
        '        If strLineLine4.Contains("NETWORK") Then '用于判断是不是网格点。如果是按网格点读取数据
        '            nAllString += 7
        '            '开始读取网格数据
        '            Dim strDate As String
        '            For i As Integer = RowPage * 40 To RowPage * 40 + 39
        '                nAllString += 1
        '                strDate = strAERMODOUT(nAllString)
        '                For j As Integer = ColPage * 9 To ColPage * 9 + 8
        '                    If strDate.Substring(14 + nCol * 13, 13) = "*************" Then
        '                        MessageBox.Show("您输入的污染物排放源强可能过大，已经超出最大范围。")
        '                        Return False
        '                    End If
        '                    Me.m_GridCon(i, j).con = strDate.Substring(14 + nCol * 13, 13)
        '                    If j >= Receptor.SubGridCart(0).Xnum - 1 Then
        '                        Exit For
        '                    End If
        '                    nCol += 1
        '                Next
        '                nCol = 0
        '                If i >= Receptor.SubGridCart(0).Ynum - 1 Then
        '                    ColPage += 1
        '                    RowPage = -1
        '                    Exit For
        '                End If
        '            Next
        '            RowPage += 1
        '        End If
        '    End If
        'Next


        '根据网格数据求最大值和最小值
        Me.m_MaxValueCon = Me.m_GridCon(0, 0).con
        Me.m_MinValueCon = Me.m_GridCon(0, 0).con
        For i As Integer = 0 To Receptor.SubGridCart(0).Ynum - 1
            For j As Integer = 0 To Receptor.SubGridCart(0).Xnum - 1
                If Me.m_MaxValueCon < Me.m_GridCon(i, j).con Then
                    Me.m_MaxValueCon = Me.m_GridCon(i, j).con
                End If
                If Me.m_MinValueCon > Me.m_GridCon(i, j).con Then
                    Me.m_MinValueCon = Me.m_GridCon(i, j).con
                End If
            Next
        Next
        Return True

    End Function
    Private Function GetCustomPeriodGridCon(ByVal strAERMODOUT As String(), ByVal Ynum As Integer, ByVal Xnum As Integer, ByVal strGroup As String, ByVal GroupSourceCount As Integer, ByVal strGrid As String, ByVal version As String) As ResultCon(,)
        Dim nVer As Integer = 0
        If version = "07026" Then
            nVer = 0
        ElseIf version = "09292" Then
            nVer = 1
        End If
        Dim AGridCon(Ynum - 1, Xnum - 1) As ResultCon
        Dim strLine As String = "" '读取一行
        Dim nCol As Integer = 0 '用于记列数
        Dim RowPage As Integer = 0 '用于标记行的页数
        Dim ColPage As Integer = 0 '用于标记列的页数
        For nAllString As Integer = 0 To strAERMODOUT.Length - 1
            strLine = strAERMODOUT(nAllString) '读取一行
            If strLine.Contains("PERIOD") And strLine.Contains("CONCENTRATION") And strLine.Contains(strGroup.ToUpper) Then
                '开始计数

                nAllString += 3
                If GroupSourceCount > 19 Then
                    nAllString += 2
                ElseIf GroupSourceCount > 7 Then
                    nAllString += 1
                End If
                Dim strLineLine4 As String = strAERMODOUT(nAllString)
                If strLineLine4.Contains("NETWORK") And strLineLine4.Contains(strGrid.ToUpper) Then '用于判断是不是网格点。如果是按网格点读取数据
                    nAllString += 7
                    '开始读取网格数据
                    Dim strDate As String
                    For i As Integer = RowPage * 40 To RowPage * 40 + 39
                        nAllString += 1
                        strDate = strAERMODOUT(nAllString)
                        For j As Integer = ColPage * 9 To ColPage * 9 + 8
                            If strDate.Substring(nVer + 14 + nCol * 13, 13) = "*************" Then
                                MessageBox.Show("您输入的污染物排放源强可能过大，已经超出最大范围。")
                                Return Nothing
                            End If
                            AGridCon(i, j).con = strDate.Substring(nVer + 14 + nCol * 13, 13)
                            If j >= Xnum - 1 Then
                                Exit For
                            End If
                            nCol += 1
                        Next
                        nCol = 0
                        If i >= Ynum - 1 Then
                            ColPage += 1
                            RowPage = -1
                            Exit For
                        End If
                    Next
                    RowPage += 1
                End If
            End If
        Next
        Return AGridCon
    End Function

    ''' <summary>
    ''' 从AERMOD.OUT文件中获取相应的期间平均网格数据
    ''' </summary>
    ''' <param name="strAERMODOUT">AERMOD.OUT文件名及路径</param>
    ''' <param name="Receptor">网格和关心点对象</param>
    ''' <param name="IsDep">是否考虑沉降</param>
    ''' <param name="strGroup">污染物组源</param>
    ''' <remarks></remarks>
    Public Function GetGridPeriodMaxDataFromAERMODOUT(ByVal strAERMODOUT As String(), ByVal Receptor As Receptor, ByVal IsDep As Boolean, ByVal strGroup As String, ByVal version As String) As Boolean
        Dim nVer As Integer = 0
        If Version = "07026" Then
            nVer = 0
        ElseIf version = "09292" Then '这个没有变化
            nVer = 0
        End If
        Dim strLine As String = "" '读取一行
        Dim nCol As Integer = 0 '用于记列数
        Dim RowPage As Integer = 0 '用于标记行的页数
        Dim ColPage As Integer = 0 '用于标记列的页数
        For nAllString As Integer = 0 To strAERMODOUT.Length - 1
            strLine = strAERMODOUT(nAllString) '读取一行
            If strLine.Contains("THE SUMMARY OF MAXIMUM PERIOD") Then
                '开始计数
                nAllString += 5

                Dim strLineLine4 As String = strAERMODOUT(nAllString)
                If strLineLine4.Contains("NETWORK") Then '用于判断是不是网格点。如果是按网格点读取数据
                    nAllString += 1
                    strLineLine4 = strAERMODOUT(nAllString)
                    If strLineLine4.Contains("CONC") Then '浓度
                        nAllString += 2
                        '开始读取网格数据
                        Dim strDate As String
                        For i As Integer = 0 To strAERMODOUT.Length - 10 - nAllString
                            nAllString += 1
                            strDate = strAERMODOUT(nAllString)
                            If strDate.Contains("*** RECEPTOR TYPES:  GC = SubGridCart(0)") Then
                                Exit For
                            Else
                                If strDate.Contains(strGroup.ToUpper) = True Then
                                    m_GridMaxCon.x = strDate.Substring(nVer + 48, 11)
                                    m_GridMaxCon.y = strDate.Substring(nVer + 61, 11)
                                    m_GridMaxCon.con = strDate.Substring(nVer + 30, 13)
                                    Exit For
                                End If
                            End If
                        Next
                    ElseIf strLineLine4.Contains("TOTAL DEPO") Then '总沉降
                        nAllString += 2
                        '开始读取网格数据
                        Dim strDate As String
                        For i As Integer = 0 To strAERMODOUT.Length - 10 - nAllString
                            nAllString += 1
                            strDate = strAERMODOUT(nAllString)
                            If strDate.Contains("*** RECEPTOR TYPES:  GC = SubGridCart(0)") Then
                                Exit For
                            Else

                                If strDate.Contains(strGroup.ToUpper) = True Then
                                    m_GridMaxDEPOS.x = strDate.Substring(nVer + 48, 11)
                                    m_GridMaxDEPOS.y = strDate.Substring(nVer + 61, 11)
                                    m_GridMaxDEPOS.DEPOS = strDate.Substring(nVer + 30, 13)
                                    Exit For
                                End If
                            End If
                        Next
                    ElseIf strLineLine4.Contains("DRY DEPO") Then '干沉降
                        nAllString += 2
                        '开始读取网格数据
                        Dim strDate As String
                        For i As Integer = 0 To strAERMODOUT.Length - 10 - nAllString
                            nAllString += 1
                            strDate = strAERMODOUT(nAllString)
                            If strDate.Contains("*** RECEPTOR TYPES:  GC = SubGridCart(0)") Then
                                Exit For
                            Else
                                If strDate.Contains(strGroup.ToUpper) = True Then
                                    m_GridMaxDDEP.x = strDate.Substring(nVer + 48, 11)
                                    m_GridMaxDDEP.y = strDate.Substring(nVer + 61, 11)
                                    m_GridMaxDDEP.DDEP = strDate.Substring(nVer + 30, 13)
                                    Exit For
                                End If
                            End If
                        Next

                    ElseIf strLineLine4.Contains("WET DEPO") Then '湿沉降
                        nAllString += 2
                        '开始读取网格数据
                        Dim strDate As String
                        For i As Integer = 0 To strAERMODOUT.Length - 10 - nAllString
                            nAllString += 1
                            strDate = strAERMODOUT(nAllString)
                            If strDate.Contains("*** RECEPTOR TYPES:  GC = SubGridCart(0)") Then
                                Exit For
                            Else
                                If strDate.Contains(strGroup.ToUpper) = True Then
                                    m_GridMaxWDEP.x = strDate.Substring(nVer + 48, 11)
                                    m_GridMaxWDEP.y = strDate.Substring(nVer + 61, 11)
                                    m_GridMaxWDEP.WDEP = strDate.Substring(nVer + 30, 13)
                                    Exit For
                                End If
                            End If
                        Next

                    End If
                End If
            End If
        Next
        Return True
    End Function

    ''' <summary>
    ''' 从AERMOD.OUT文件中获取相应的期间平均关心点数据
    ''' </summary>
    ''' <param name="strAERMODOUT">AERMOD.OUT文件名及路径</param>
    ''' <param name="Receptor">网格和关心点对象</param>
    ''' <param name="IsDep">是否考虑沉降</param>
    ''' <param name="strGroup">污染物组源</param>
    ''' <remarks></remarks>
    Public Function GetDiscPeriodDateFromAERMODOUT(ByVal strAERMODOUT As String(), ByVal Receptor As Receptor, ByVal IsDep As Boolean, ByVal strGroup As String, ByVal GroupSourceCount As Integer, ByVal version As String) As Boolean
        Dim nVer As Integer = 0
        If Version = "07026" Then
            nVer = 0
        ElseIf Version = "09292" Then
            nVer = 1
        End If
        ReDim Preserve Me.m_DiscCon(Receptor.DiscCarts.Length - 1)
        ReDim Preserve Me.m_DiscDEPOS(Receptor.DiscCarts.Length - 1)
        ReDim Preserve Me.m_DiscDDEP(Receptor.DiscCarts.Length - 1)
        ReDim Preserve Me.m_DiscWDEP(Receptor.DiscCarts.Length - 1)
        Dim strLine As String = "" '读取一行
        Dim RowPage As Integer = 0 '用于标记行的页数
        For nAllString As Integer = 0 To strAERMODOUT.Length - 1
            strLine = strAERMODOUT(nAllString) '读取一行
            If strLine.Contains("PERIOD") And strLine.Contains("CONCENTRATION") And strLine.Contains(strGroup.ToUpper) Then
                '开始计数
                nAllString += 3
                If GroupSourceCount > 19 Then
                    nAllString += 2
                ElseIf GroupSourceCount > 7 Then
                    nAllString += 1
                End If
                Dim strLineLine4 As String = strAERMODOUT(nAllString)
                If strLineLine4.Contains("DISCRETE") Then '用于判断是不是网格点。如果是按网格点读取数据
                    nAllString += 5
                    '开始读取网格数据
                    Dim strDate As String
                    Dim IsEnd As Boolean = False
                    For i As Integer = RowPage * 40 To RowPage * 40 + 39
                        nAllString += 1
                        strDate = strAERMODOUT(nAllString)
                        Me.m_DiscCon(i * 2).x = strDate.Substring(nVer + 4, 13)
                        Me.m_DiscCon(i * 2).y = strDate.Substring(nVer + 18, 13)
                        Me.m_DiscCon(i * 2).con = strDate.Substring(nVer + 33, 13)
                        If (i + 1) * 2 <= Receptor.DiscCarts.Length Then
                            Me.m_DiscCon(i * 2 + 1).x = strDate.Substring(nVer + 64, 13)
                            Me.m_DiscCon(i * 2 + 1).y = strDate.Substring(nVer + 78, 13)
                            Me.m_DiscCon(i * 2 + 1).con = strDate.Substring(nVer + 93, 13)
                        End If
                        If (i + 1) * 2 >= Receptor.DiscCarts.Length Then
                            IsEnd = True
                            RowPage = 0
                            Exit For
                        End If
                    Next
                    If IsEnd = False Then
                        RowPage += 1
                    End If
                End If
            ElseIf strLine.Contains("PERIOD") And strLine.Contains("TOTAL DEPOSITION") And strLine.Contains(strGroup.ToUpper) Then
                '开始计数
                nAllString += 3
                If GroupSourceCount > 19 Then
                    nAllString += 2
                ElseIf GroupSourceCount > 7 Then
                    nAllString += 1
                End If
                Dim strLineLine4 As String = strAERMODOUT(nAllString)
                If strLineLine4.Contains("DISCRETE") Then '用于判断是不是网格点。如果是按网格点读取数据
                    nAllString += 5
                    '开始读取网格数据
                    Dim strDate As String
                    Dim IsEnd As Boolean = False
                    For i As Integer = RowPage * 40 To RowPage * 40 + 39
                        nAllString += 1
                        strDate = strAERMODOUT(nAllString)
                        Me.m_DiscDEPOS(i * 2).x = strDate.Substring(nVer + 4, 13)
                        Me.m_DiscDEPOS(i * 2).y = strDate.Substring(nVer + 18, 13)
                        Me.m_DiscDEPOS(i * 2).DEPOS = strDate.Substring(nVer + 33, 13)
                        If (i + 1) * 2 <= Receptor.DiscCarts.Length Then
                            Me.m_DiscDEPOS(i * 2 + 1).x = strDate.Substring(nVer + 64, 13)
                            Me.m_DiscDEPOS(i * 2 + 1).y = strDate.Substring(nVer + 78, 13)
                            Me.m_DiscDEPOS(i * 2 + 1).DEPOS = strDate.Substring(nVer + 93, 13)
                        End If
                        If (i + 1) * 2 >= Receptor.DiscCarts.Length Then
                            IsEnd = True
                            RowPage = 0
                            Exit For
                        End If
                    Next
                    If IsEnd = False Then
                        RowPage += 1
                    End If
                End If

            ElseIf strLine.Contains("PERIOD") And strLine.Contains("DRY DEPOSITION") And strLine.Contains(strGroup.ToUpper) Then
                '开始计数
                nAllString += 3
                If GroupSourceCount > 19 Then
                    nAllString += 2
                ElseIf GroupSourceCount > 7 Then
                    nAllString += 1
                End If
                Dim strLineLine4 As String = strAERMODOUT(nAllString)
                If strLineLine4.Contains("DISCRETE") Then '用于判断是不是网格点。如果是按网格点读取数据
                    nAllString += 5
                    '开始读取网格数据
                    Dim strDate As String
                    Dim IsEnd As Boolean = False
                    For i As Integer = RowPage * 40 To RowPage * 40 + 39
                        nAllString += 1
                        strDate = strAERMODOUT(nAllString)
                        Me.m_DiscDDEP(i * 2).x = strDate.Substring(nVer + 4, 13)
                        Me.m_DiscDDEP(i * 2).y = strDate.Substring(nVer + 18, 13)
                        Me.m_DiscDDEP(i * 2).DDEP = strDate.Substring(nVer + 33, 13)
                        If (i + 1) * 2 <= Receptor.DiscCarts.Length Then
                            Me.m_DiscDDEP(i * 2 + 1).x = strDate.Substring(nVer + 64, 13)
                            Me.m_DiscDDEP(i * 2 + 1).y = strDate.Substring(nVer + 78, 13)
                            Me.m_DiscDDEP(i * 2 + 1).DDEP = strDate.Substring(nVer + 93, 13)
                        End If
                        If (i + 1) * 2 >= Receptor.DiscCarts.Length Then
                            IsEnd = True
                            RowPage = 0
                            Exit For
                        End If
                    Next
                    If IsEnd = False Then
                        RowPage += 1
                    End If
                End If
            ElseIf strLine.Contains("PERIOD") And strLine.Contains("WET DEPOSITION") And strLine.Contains(strGroup.ToUpper) Then
                '开始计数
                nAllString += 3
                If GroupSourceCount > 19 Then
                    nAllString += 2
                ElseIf GroupSourceCount > 7 Then
                    nAllString += 1
                End If
                Dim strLineLine4 As String = strAERMODOUT(nAllString)
                If strLineLine4.Contains("DISCRETE") Then '用于判断是不是网格点。如果是按网格点读取数据
                    nAllString += 5
                    '开始读取网格数据
                    Dim strDate As String
                    Dim IsEnd As Boolean = False
                    For i As Integer = RowPage * 40 To RowPage * 40 + 39
                        nAllString += 1
                        strDate = strAERMODOUT(nAllString)
                        Me.m_DiscWDEP(i * 2).x = strDate.Substring(nVer + 4, 13)
                        Me.m_DiscWDEP(i * 2).y = strDate.Substring(nVer + 18, 13)
                        Me.m_DiscWDEP(i * 2).WDEP = strDate.Substring(nVer + 33, 13)
                        If (i + 1) * 2 <= Receptor.DiscCarts.Length Then
                            Me.m_DiscWDEP(i * 2 + 1).x = strDate.Substring(nVer + 64, 13)
                            Me.m_DiscWDEP(i * 2 + 1).y = strDate.Substring(nVer + 78, 13)
                            Me.m_DiscWDEP(i * 2 + 1).WDEP = strDate.Substring(nVer + 93, 13)
                        End If
                        If (i + 1) * 2 >= Receptor.DiscCarts.Length Then
                            IsEnd = True
                            RowPage = 0
                            Exit For
                        End If
                    Next
                    If IsEnd = False Then
                        RowPage += 1
                    End If
                End If

            End If
        Next
        Return True
    End Function


    ''' <summary>
    ''' 从AERMOD.OUT文件中获取相应的平均时间内的关心点数据
    ''' </summary>
    ''' <param name="strAERMODOUT">AERMOD.OUT文件内容</param>
    ''' <param name="Receptor">网格和关心点对象</param>
    ''' <param name="IsDep">是否考虑沉降</param>
    ''' <param name="strGroup">污染物组源</param>
    ''' <remarks></remarks>
    Public Function GetDiscDateFromAERMODOUT(ByVal strAERMODOUT As String(), ByVal Receptor As Receptor, ByVal IsDep As Boolean, ByVal strAerageTime As String, ByVal strHIGHEST As String, ByVal strGroup As String, ByVal GroupSourceCount As Integer, ByVal version As String) As Boolean
        Dim nVer As Integer = 0
        If Version = "07026" Then
            nVer = 0
        ElseIf Version = "09292" Then
            nVer = 1
        End If
        ReDim Preserve Me.m_DiscCon(Receptor.DiscCarts.Length - 1)
        ReDim Preserve Me.m_DiscDEPOS(Receptor.DiscCarts.Length - 1)
        ReDim Preserve Me.m_DiscDDEP(Receptor.DiscCarts.Length - 1)
        ReDim Preserve Me.m_DiscWDEP(Receptor.DiscCarts.Length - 1)
        Dim strLine As String = "" '读取一行
        Dim RowPage As Integer = 0 '用于标记行的页数
        For nAllString As Integer = 0 To strAERMODOUT.Length - 1

            strLine = strAERMODOUT(nAllString) '读取一行
            If strLine.Contains(strHIGHEST) And strLine.Contains(strAerageTime) And strLine.Contains("CONCENTRATION") And strLine.Contains(strGroup.ToUpper) Then
                '开始计数
                nAllString += 3
                If GroupSourceCount > 19 Then
                    nAllString += 2
                ElseIf GroupSourceCount > 7 Then
                    nAllString += 1
                End If
                Dim strLineLine4 As String = strAERMODOUT(nAllString)
                If strLineLine4.Contains("DISCRETE") Then '用于判断是不是网格点。如果是按网格点读取数据
                    nAllString += 5
                    '开始读取网格数据
                    Dim strDate As String
                    Dim IsEnd As Boolean = False
                    For i As Integer = RowPage * 40 To RowPage * 40 + 39
                        nAllString += 1
                        strDate = strAERMODOUT(nAllString)
                        Me.m_DiscCon(i * 2).x = strDate.Substring(nVer + 3, 13)
                        Me.m_DiscCon(i * 2).y = strDate.Substring(nVer + 16, 13)
                        Me.m_DiscCon(i * 2).con = strDate.Substring(nVer + 31, 13)
                        Me.m_DiscCon(i * 2).dateD = strDate.Substring(nVer + 47, 8)
                        If (i + 1) * 2 <= Receptor.DiscCarts.Length Then
                            Me.m_DiscCon(i * 2 + 1).x = strDate.Substring(nVer + 68, 13)
                            Me.m_DiscCon(i * 2 + 1).y = strDate.Substring(nVer + 81, 13)
                            Me.m_DiscCon(i * 2 + 1).con = strDate.Substring(nVer + 96, 13)
                            Me.m_DiscCon(i * 2 + 1).dateD = strDate.Substring(nVer + 112, 8)
                        End If
                        If (i + 1) * 2 >= Receptor.DiscCarts.Length Then
                            IsEnd = True
                            RowPage = 0
                            Exit For
                        End If
                    Next
                    If IsEnd = False Then
                        RowPage += 1
                    End If
                End If
            ElseIf strLine.Contains(strHIGHEST) And strLine.Contains(strAerageTime) And strLine.Contains("TOTAL DEPOSITION") And strLine.Contains(strGroup.ToUpper) Then
                '开始计数
                nAllString += 3
                If GroupSourceCount > 19 Then
                    nAllString += 2
                ElseIf GroupSourceCount > 7 Then
                    nAllString += 1
                End If
                Dim strLineLine4 As String = strAERMODOUT(nAllString)
                If strLineLine4.Contains("DISCRETE") Then '用于判断是不是网格点。如果是按网格点读取数据
                    nAllString += 5
                    '开始读取网格数据
                    Dim strDate As String
                    Dim IsEnd As Boolean = False
                    For i As Integer = RowPage * 40 To RowPage * 40 + 39
                        nAllString += 1
                        strDate = strAERMODOUT(nAllString)
                        Me.m_DiscDEPOS(i * 2).x = strDate.Substring(nVer + 3, 13)
                        Me.m_DiscDEPOS(i * 2).y = strDate.Substring(nVer + 16, 13)
                        Me.m_DiscDEPOS(i * 2).DEPOS = strDate.Substring(nVer + 31, 13)
                        Me.m_DiscDEPOS(i * 2).dateD = strDate.Substring(nVer + 47, 8)
                        If (i + 1) * 2 <= Receptor.DiscCarts.Length Then
                            Me.m_DiscDEPOS(i * 2 + 1).x = strDate.Substring(nVer + 68, 13)
                            Me.m_DiscDEPOS(i * 2 + 1).y = strDate.Substring(nVer + 81, 13)
                            Me.m_DiscDEPOS(i * 2 + 1).DEPOS = strDate.Substring(nVer + 96, 13)
                            Me.m_DiscDEPOS(i * 2 + 1).dateD = strDate.Substring(nVer + 112, 8)
                        End If
                        If (i + 1) * 2 >= Receptor.DiscCarts.Length Then
                            IsEnd = True
                            RowPage = 0
                            Exit For
                        End If
                    Next
                    If IsEnd = False Then
                        RowPage += 1
                    End If
                End If
            ElseIf strLine.Contains(strHIGHEST) And strLine.Contains(strAerageTime) And strLine.Contains("DRY DEPOSITION") And strLine.Contains(strGroup.ToUpper) Then
                '开始计数
                nAllString += 3
                If GroupSourceCount > 19 Then
                    nAllString += 2
                ElseIf GroupSourceCount > 7 Then
                    nAllString += 1
                End If
                Dim strLineLine4 As String = strAERMODOUT(nAllString)
                If strLineLine4.Contains("DISCRETE") Then '用于判断是不是网格点。如果是按网格点读取数据
                    nAllString += 5
                    '开始读取网格数据
                    Dim strDate As String
                    Dim IsEnd As Boolean = False
                    For i As Integer = RowPage * 40 To RowPage * 40 + 39
                        nAllString += 1
                        strDate = strAERMODOUT(nAllString)
                        Me.m_DiscDDEP(i * 2).x = strDate.Substring(nVer + 3, 13)
                        Me.m_DiscDDEP(i * 2).y = strDate.Substring(nVer + 16, 13)
                        Me.m_DiscDDEP(i * 2).DDEP = strDate.Substring(nVer + 31, 13)
                        Me.m_DiscDDEP(i * 2).dateD = strDate.Substring(nVer + 47, 8)
                        If (i + 1) * 2 <= Receptor.DiscCarts.Length Then
                            Me.m_DiscDDEP(i * 2 + 1).x = strDate.Substring(nVer + 68, 13)
                            Me.m_DiscDDEP(i * 2 + 1).y = strDate.Substring(nVer + 81, 13)
                            Me.m_DiscDDEP(i * 2 + 1).DDEP = strDate.Substring(nVer + 96, 13)
                            Me.m_DiscDDEP(i * 2 + 1).dateD = strDate.Substring(nVer + 112, 8)
                        End If
                        If (i + 1) * 2 >= Receptor.DiscCarts.Length Then
                            IsEnd = True
                            RowPage = 0
                            Exit For
                        End If
                    Next
                    If IsEnd = False Then
                        RowPage += 1
                    End If
                End If
            ElseIf strLine.Contains(strHIGHEST) And strLine.Contains(strAerageTime) And strLine.Contains("WET DEPOSITION") And strLine.Contains(strGroup.ToUpper) Then
                '开始计数
                nAllString += 3
                If GroupSourceCount > 19 Then
                    nAllString += 2
                ElseIf GroupSourceCount > 7 Then
                    nAllString += 1
                End If
                Dim strLineLine4 As String = strAERMODOUT(nAllString)
                If strLineLine4.Contains("DISCRETE") Then '用于判断是不是网格点。如果是按网格点读取数据
                    nAllString += 5
                    '开始读取网格数据
                    Dim strDate As String
                    Dim IsEnd As Boolean = False
                    For i As Integer = RowPage * 40 To RowPage * 40 + 39
                        nAllString += 1
                        strDate = strAERMODOUT(nAllString)
                        Me.m_DiscWDEP(i * 2).x = strDate.Substring(nVer + 3, 13)
                        Me.m_DiscWDEP(i * 2).y = strDate.Substring(nVer + 16, 13)
                        Me.m_DiscWDEP(i * 2).WDEP = strDate.Substring(nVer + 31, 13)
                        Me.m_DiscWDEP(i * 2).dateD = strDate.Substring(nVer + 47, 8)
                        If (i + 1) * 2 <= Receptor.DiscCarts.Length Then
                            Me.m_DiscWDEP(i * 2 + 1).x = strDate.Substring(nVer + 68, 13)
                            Me.m_DiscWDEP(i * 2 + 1).y = strDate.Substring(nVer + 81, 13)
                            Me.m_DiscWDEP(i * 2 + 1).WDEP = strDate.Substring(nVer + 96, 13)
                            Me.m_DiscWDEP(i * 2 + 1).dateD = strDate.Substring(nVer + 112, 8)
                        End If
                        If (i + 1) * 2 >= Receptor.DiscCarts.Length Then
                            IsEnd = True
                            RowPage = 0
                            Exit For
                        End If
                    Next
                    If IsEnd = False Then
                        RowPage += 1
                    End If
                End If

            End If
        Next
        Return True
    End Function

#Region "暂时用不上的函数"
    ''' <summary>
    ''' 从结果数据文件中读取数据。
    ''' </summary>
    ''' <param name="rows">网格点的行数</param>
    ''' <param name="cols">网格点的列数</param>
    ''' <param name="DiscCount">离散点的个数</param>
    ''' <param name="IsDep">是否考虑干湿沉降</param>
    ''' <remarks></remarks>
    Public Sub GetDataFromPlotFile(ByVal rows As Integer, ByVal cols As Integer, ByVal DiscCount As Integer, ByVal IsDep As Boolean, ByVal m_Data As String)
        GetGridDateFromPlotFile(rows, cols, m_Data)
        'GetGridMaxDate(rows, cols, IsDep, m_Data)
        'GetDiscData(rows, cols, DiscCount, IsDep, m_Data)
    End Sub
    ''' <summary>
    ''' 取得给定污染物的网格点的数据
    ''' </summary>
    ''' <param name="rows"></param>
    ''' <param name="cols"></param>
    ''' <remarks></remarks>
    Private Sub GetGridDateFromPlotFile(ByVal rows As Integer, ByVal cols As Integer, ByVal m_Data As String)
        '初始化数组
        Dim nstart As Integer = 0
        Dim nend As Integer = m_Data.IndexOf(vbCrLf) '取得第一个回车符的位置
        Dim substr As String = m_Data.Substring(0, nend - nstart) '取得第一行
        While substr.IndexOf("*") >= 0
            nstart = nend + 1
            nend = m_Data.IndexOf(vbCrLf, nstart)
            substr = m_Data.Substring(nstart + 1, nend - nstart - 1)
        End While
        m_MaxValueCon = CAermod.StringHandle.GetString(substr, 3)
        m_MinValueCon = CAermod.StringHandle.GetString(substr, 3)
        For i As Integer = 0 To rows - 1
            For j As Integer = 0 To cols - 1
                Try
                    m_GridCon(rows - 1 - i, j).con = CAermod.StringHandle.GetString(substr, 3)
                    If m_GridCon(rows - 1 - i, j).con > Me.m_MaxValueCon Then '求得最大值
                        Me.m_MaxValueCon = m_GridCon(rows - 1 - i, j).con
                    End If
                    If m_GridCon(rows - 1 - i, j).con < Me.m_MinValueCon And m_GridCon(rows - 1 - i, j).con <> 0 Then '求得最小值
                        Me.m_MinValueCon = m_GridCon(rows - 1 - i, j).con
                    End If
                    nstart = nend + 1
                    nend = m_Data.IndexOf(vbCrLf, nstart)
                    If nend > 0 Then
                        substr = m_Data.Substring(nstart + 1, nend - nstart - 1)
                    Else
                        Exit Sub
                    End If
                Catch ex As Exception
                    MsgBox("您输入的污染物源强可能太大，已经超出了aermod的范围")
                End Try
            Next
        Next



    End Sub
    ''' <summary>
    ''' 取得给定污染物的网格点的数据中的最大值
    ''' </summary>
    ''' <param name="rows"></param>
    ''' <param name="cols"></param>
    ''' <remarks></remarks>
    'Private Sub GetGridMaxDate(ByVal rows As Integer, ByVal cols As Integer, ByVal IsDep As Boolean, ByVal m_Data As String)
    '    Dim A(rows - 1, cols - 1) As Double
    '    Dim nstart As Integer = 0
    '    Dim nend As Integer = m_Data.IndexOf(vbCrLf) '取得第一个回车符的位置
    '    Dim substr As String = m_Data.Substring(0, nend - nstart) '取得第一行
    '    While substr.IndexOf("*") >= 0
    '        nstart = nend + 1
    '        nend = m_Data.IndexOf(vbCrLf, nstart)
    '        substr = m_Data.Substring(nstart + 1, nend - nstart - 1)
    '    End While
    '    m_MaxValue = CAermod.StringHandle.GetString(substr, 3)
    '    m_MinValue = CAermod.StringHandle.GetString(substr, 3)
    '    For i As Integer = 0 To rows - 1
    '        For j As Integer = 0 To cols - 1
    '            Try
    '                A(rows - 1 - i, j) = CAermod.StringHandle.GetString(substr, 3)
    '                If A(rows - 1 - i, j) > Me.m_MaxValue Then '求得最大值
    '                    Me.m_MaxValue = A(rows - 1 - i, j)
    '                    m_GridMaxData.x = CAermod.StringHandle.GetString(substr, 1) '关心点的X坐标
    '                    m_GridMaxData.y = CAermod.StringHandle.GetString(substr, 2) '关心点的Y坐标
    '                    m_GridMaxData.con = CAermod.StringHandle.GetString(substr, 3) '关心点的浓度值
    '                    If IsDep Then
    '                        m_GridMaxData.DEPOS = CAermod.StringHandle.GetString(substr, 4)
    '                        m_GridMaxData.DDEP = CAermod.StringHandle.GetString(substr, 5)
    '                        m_GridMaxData.WDEP = CAermod.StringHandle.GetString(substr, 6)
    '                        m_GridMaxData.dateD = CAermod.StringHandle.GetString(substr, 14) '关心点的日期
    '                    Else
    '                        m_GridMaxData.dateD = CAermod.StringHandle.GetString(substr, 11) '关心点的日期
    '                    End If
    '                End If
    '                If A(rows - 1 - i, j) < Me.m_MinValue And A(rows - 1 - i, j) <> 0 Then '求得最小值
    '                    Me.m_MinValue = A(rows - 1 - i, j)
    '                End If
    '                nstart = nend + 1
    '                nend = m_Data.IndexOf(vbCrLf, nstart)
    '                If nend > 0 Then
    '                    substr = m_Data.Substring(nstart + 1, nend - nstart - 1)
    '                Else
    '                    Exit Sub
    '                End If
    '            Catch ex As Exception
    '                MsgBox("您输入的污染物源强可能太大，已经超出了aermod的范围")
    '            End Try
    '        Next
    '    Next
    'End Sub
    ''' <summary>
    ''' 根据结果字符串输出浓度、坐标、时间及干湿沉降等
    ''' </summary>
    ''' <param name="rows">网格点的行数</param>
    ''' <param name="cols">网格点的列数</param>
    ''' <param name="DiscCount">离散点的个数</param>
    ''' <param name="IsDep">是否考虑干湿沉降</param>
    ''' <remarks></remarks>
    'Private Sub GetDiscData(ByVal rows As Integer, ByVal cols As Integer, ByVal DiscCount As Integer, ByVal IsDep As Boolean, ByVal m_Data As String)
    '    ReDim m_DiscData(DiscCount - 1)  '用于储存关心点数组
    '    Dim nstart As Integer = 0
    '    Dim nend As Integer = m_Data.IndexOf(vbCrLf) '取得第一个回车符的位置
    '    Dim substr As String = m_Data.Substring(0, nend - nstart) '取得第一行
    '    While substr.IndexOf("*") >= 0
    '        nstart = nend + 1
    '        nend = m_Data.IndexOf(vbCrLf, nstart)
    '        substr = m_Data.Substring(nstart + 1, nend - nstart - 1)
    '    End While
    '    For i As Integer = 0 To rows - 1
    '        For j As Integer = 0 To cols - 1
    '            nstart = nend + 1
    '            nend = m_Data.IndexOf(vbCrLf, nstart)
    '            If nend > 0 Then
    '                substr = m_Data.Substring(nstart + 1, nend - nstart - 1)
    '            Else
    '                Exit Sub
    '            End If
    '        Next
    '    Next
    '    If IsDep = True Then '考虑干湿沉降
    '        For i As Integer = 0 To DiscCount - 1
    '            m_DiscData(i).x = CAermod.StringHandle.GetString(substr, 1) '关心点的X坐标
    '            m_DiscData(i).y = CAermod.StringHandle.GetString(substr, 2) '关心点的Y坐标
    '            m_DiscData(i).con = CAermod.StringHandle.GetString(substr, 3) '关心点的浓度值
    '            m_DiscData(i).DEPOS = CAermod.StringHandle.GetString(substr, 4) '关心点的总沉积
    '            m_DiscData(i).DDEP = CAermod.StringHandle.GetString(substr, 5) '关心点的干沉积
    '            m_DiscData(i).WDEP = CAermod.StringHandle.GetString(substr, 6) '关心点的湿沉积

    '            m_DiscData(i).dateD = CAermod.StringHandle.GetString(substr, 13) '关心点的日期
    '            nstart = nend + 1
    '            nend = m_Data.IndexOf(vbCrLf, nstart)
    '            If nend > 0 Then
    '                substr = m_Data.Substring(nstart + 1, nend - nstart - 1)
    '            Else
    '                Exit Sub
    '            End If
    '        Next
    '    Else '不考虑干湿沉降
    '        For i As Integer = 0 To DiscCount - 1
    '            m_DiscData(i).x = CAermod.StringHandle.GetString(substr, 1) '关心点的X坐标
    '            m_DiscData(i).y = CAermod.StringHandle.GetString(substr, 2) '关心点的Y坐标
    '            m_DiscData(i).con = CAermod.StringHandle.GetString(substr, 3) '关心点的浓度值
    '            m_DiscData(i).dateD = CAermod.StringHandle.GetString(substr, 10) '关心点的日期
    '            nstart = nend + 1
    '            nend = m_Data.IndexOf(vbCrLf, nstart)
    '            If nend > 0 Then
    '                substr = m_Data.Substring(nstart + 1, nend - nstart - 1)
    '            Else
    '                Exit Sub
    '            End If
    '        Next
    '    End If
    'End Sub
#End Region

End Class


